{include file="header.html"}
<div id="page_main" class="main-right">
  <div id="rightTop">
    <p>{$lang.article}</p>
    <ul class="subnav">
      <li><span>{$lang.manage}</span></li>
      <li><a class="btn1" href="{url route='article/add'}">{$lang.add}</a></li>
    </ul>
  </div>
  <div class="search-form clearfix">
    <form method="get" id="formSearch">
      <input type="hidden" name="r" value="article/index" />
      {$lang.title}
      <input class="queryInput" type="text" name="title" value="{$smarty.get.title|escape}" />
      {$lang.select_acategory}
      <select class="querySelect" id="cate_id" name="cate_id">
        <option value="">{$lang.select_pls}</option>
        
	  		{html_options options=$acategories selected=$smarty.get.cate_id}
    	
      </select>
      {$lang.articletype}
      <select name="articletype">
        <option value="">{$lang.select_pls}</option>
        <option value="1"{if $smarty.get.articletype eq 1} selected="selected"{/if}>{$lang.backend_article}</option>
        <option value="2"{if $smarty.get.articletype eq 2} selected="selected"{/if}>{$lang.store_article}</option>
      </select>
      <input type="submit" class="formbtn" value="{$lang.query}" />
      <!--{if $filtered}--> 
      <a class="formbtn formbtn1" href="{url route='article/index'}">{$lang.cancel_query}</a> 
      <!--{/if}-->
    </form>
  </div>
  <div id="flexigrid"></div>
</div>
<script type="text/javascript">
$(function(){
    $("#flexigrid").flexigrid({
    	url: url(['article/index', $("#formSearch").serializeJson()]),
    	colModel : [
    		{ display: '{$lang.operation}', name : 'operation', width : 150, sortable : false, align: 'center', className: 'handle'},
			  { display: '{$lang.title}', name : 'title', width : 350, sortable : true, align: 'center'},
    		{ display: '{$lang.cate_name}', name : 'cate_name', width : 150, sortable : true, align: 'center'}, 
			  { display: '{$lang.articletype}', name : 'store_id', width : 100, sortable : true, align: 'center'},  
			  { display: '{$lang.sort_order}', name : 'sort_order', width : 100, sortable : true, align: 'center'},   		
			  { display: '{$lang.if_show}', name : 'if_show', width: 100, sortable : true, align : 'center'},
			  { display: '{$lang.add_time}', name : 'add_time', width: 120, sortable : true, align : 'center'}   		
    	],
      buttons : [
           { display: '<i class="fa fa-plus"></i>{$lang.add_data}', name : 'add', bclass : 'add', title : '{$lang.add_data}', onpress : fg_operate },
          { display: '<i class="fa fa-trash"></i>{$lang.batch_del}', name : 'del', bclass : 'del', title : '{$lang.batch_del_for_selected}', onpress : fg_operate }
      ],
    	sortname: "add_time",
    	sortorder: "desc",
    	title: '{$lang.article_list}'
    });
});
function fg_operate(name, bDiv) {
	if(name == 'add'){
		window.location.href = "{url route='article/add'}";
		return false;
	}
	
	var itemlist = new Array();
	$('.trSelected',bDiv).each(function(){
		itemlist.push($(this).attr('data-id'));
	});
	if (name == 'del') {
	  if($('.trSelected',bDiv).length == 0){
			layer.msg(lang.no_selected_item);
			return false;
	  }
    fg_delete(itemlist, 'article');
	}
}
</script> 
{include file="footer.html"} 